package com.baby.work.domain.thread;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class MyThread implements Runnable {
    @Override
    public void run() {
        try {
            Thread.sleep(1000); // 阻塞
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("thread test"); // 运行
    }

    public static void main(String[] args) throws Exception {
        MyThread myThread = new MyThread();
        Thread thread = new Thread(myThread, "my thread1"); // 新建
        thread.start(); // 就绪
        System.out.println("======end===");

        AtomicBoolean data = new AtomicBoolean(false);
        data.compareAndSet(false, true);
        System.out.println(data + "======");
    }
}

